<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>服务管理 - 北极星后台</title>
    <style>
        /* 基础样式 */
        :root {
            --primary-color: #3498db;
            --secondary-color: #2c3e50;
            --danger-color: #e74c3c;
            --success-color: #2ecc71;
            --warning-color: #f39c12;
            --light-color: #ecf0f1;
            --dark-color: #34495e;
            --sidebar-width: 250px;
            --transition-speed: 0.3s;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f5f7fa;
            color: #333;
            line-height: 1.6;
        }

        /* 按钮样式 */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 8px 15px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            font-size: 14px;
            transition: all var(--transition-speed);
            gap: 8px;
        }

        .btn-primary {
            background-color: var(--primary-color);
            color: white;
        }

        .btn-danger {
            background-color: var(--danger-color);
            color: white;
        }

        .btn-success {
            background-color: var(--success-color);
            color: white;
        }

        .btn-secondary {
            background-color: #95a5a6;
            color: white;
        }

        .btn-sm {
            padding: 5px 10px;
            font-size: 12px;
        }

        .btn:hover {
            opacity: 0.9;
            transform: translateY(-2px);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .btn:active {
            transform: translateY(0);
        }

        /* 卡片样式 */
        .card {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
            margin-bottom: 20px;
            overflow: hidden;
            transition: all var(--transition-speed);
        }

        .card:hover {
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
        }

        .card-header {
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #f8f9fa;
        }

        .card-body {
            padding: 20px;
        }

        /* 服务列表样式 */
        .services-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .service-item {
            display: flex;
            gap: 20px;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            transition: all var(--transition-speed);
            border-left: 4px solid var(--primary-color);
        }

        .service-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            border-left-color: var(--secondary-color);
        }

        .service-icon {
            font-size: 40px;
            color: var(--primary-color);
            min-width: 60px;
            text-align: center;
            transition: all var(--transition-speed);
        }

        .service-item:hover .service-icon {
            color: var(--secondary-color);
            transform: scale(1.1);
        }

        .service-content {
            flex: 1;
        }

        .service-content h4 {
            margin-bottom: 10px;
            color: var(--secondary-color);
            font-size: 18px;
        }

        .service-content p {
            color: #7f8c8d;
            font-size: 14px;
            line-height: 1.5;
        }

        .service-actions {
            margin-top: 15px;
            display: flex;
            gap: 10px;
        }

        /* 表单样式 */
        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
            color: var(--secondary-color);
        }

        .form-control {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            transition: all var(--transition-speed);
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
            outline: none;
        }

        textarea.form-control {
            min-height: 100px;
            resize: vertical;
        }

        select.form-control {
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            background-size: 12px;
            padding-right: 30px;
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1050;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            background-color: rgba(0, 0, 0, 0.5);
            opacity: 0;
            transition: opacity var(--transition-speed);
        }

        .modal.show {
            display: block;
            opacity: 1;
        }

        .modal-dialog {
            max-width: 600px;
            margin: 30px auto;
            transform: translateY(-50px);
            transition: transform var(--transition-speed);
        }

        .modal.show .modal-dialog {
            transform: translateY(0);
        }

        .modal-content {
            background-color: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
        }

        .modal-header {
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #f8f9fa;
        }

        .modal-title {
            font-size: 18px;
            font-weight: 600;
            color: var(--secondary-color);
        }

        .modal-body {
            padding: 20px;
            max-height: 70vh;
            overflow-y: auto;
        }

        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            background-color: #f8f9fa;
        }

        .close {
            font-size: 24px;
            font-weight: bold;
            color: #7f8c8d;
            background: none;
            border: none;
            cursor: pointer;
            transition: color var(--transition-speed);
        }

        .close:hover {
            color: var(--danger-color);
        }

        /* 顶部导航 */
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: white;
            padding: 15px 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            margin-bottom: 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .user-info img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            object-fit: cover;
        }

        .user-info span {
            font-weight: 500;
        }

        /* 图标选择器样式 */
        .icon-selector {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
            gap: 10px;
            margin-top: 10px;
        }

        .icon-option {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 10px;
            border-radius: 4px;
            cursor: pointer;
            transition: all var(--transition-speed);
            border: 1px solid transparent;
        }

        .icon-option:hover {
            background-color: rgba(52, 152, 219, 0.1);
        }

        .icon-option.selected {
            border-color: var(--primary-color);
            background-color: rgba(52, 152, 219, 0.1);
        }

        .icon-option i {
            font-size: 24px;
            margin-bottom: 5px;
            color: var(--secondary-color);
        }

        .icon-option span {
            font-size: 12px;
            text-align: center;
        }

        /* 动画 */
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        @keyframes slideIn {
            from { transform: translateY(20px); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }

        @keyframes fadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .service-item {
                flex-direction: column;
                gap: 15px;
            }

            .service-icon {
                text-align: left;
            }

            .modal-dialog {
                margin: 20px auto;
                width: 95%;
            }
        }
    </style>
    <!-- 引入Font Awesome图标 -->
    <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">-->
    <link rel="stylesheet" href="../../fontawesome-free-6.7.2-web/css/all.min.css">
</head>
<body>
<div class="main-content">
    <!--<div class="top-nav">
        <div>
            <button class="btn btn-primary" id="toggleSidebar">
                <i class="fas fa-bars"></i>
            </button>
        </div>
        <div class="user-info">
            <img src="https://via.placeholder.com/40" alt="用户头像">
            <span>北极星</span>
        </div>
    </div>-->

    <div class="card">
        <div class="card-header">
            <h3>服务管理</h3>
            <button class="btn btn-primary" id="addServiceBtn">
                <i class="fas fa-plus"></i> 添加服务
            </button>
        </div>
        <div class="card-body">
            <div class="services-list">
                <div class="service-item">
                    <div class="service-icon">
                        <i class="fas fa-laptop-code"></i>
                    </div>
                    <div class="service-content">
                        <h4>网站开发</h4>
                        <p>从简单的企业官网到复杂的电商平台，为您打造响应式、高性能的网站解决方案。</p>
                        <div class="service-actions">
                            <button class="btn btn-sm btn-primary edit-service-btn"><i class="fas fa-edit"></i> 编辑</button>
                            <button class="btn btn-sm btn-danger delete-service-btn"><i class="fas fa-trash"></i> 删除</button>
                        </div>
                    </div>
                </div>
                <div class="service-item">
                    <div class="service-icon">
                        <i class="fas fa-mobile-alt"></i>
                    </div>
                    <div class="service-content">
                        <h4>移动应用开发</h4>
                        <p>iOS和Android原生应用开发，跨平台混合应用开发，满足您的移动业务需求。</p>
                        <div class="service-actions">
                            <button class="btn btn-sm btn-primary edit-service-btn"><i class="fas fa-edit"></i> 编辑</button>
                            <button class="btn btn-sm btn-danger delete-service-btn"><i class="fas fa-trash"></i> 删除</button>
                        </div>
                    </div>
                </div>
                <div class="service-item">
                    <div class="service-icon">
                        <i class="fas fa-server"></i>
                    </div>
                    <div class="service-content">
                        <h4>后端开发</h4>
                        <p>构建稳定、安全、可扩展的后端系统，提供API开发、数据库设计等服务。</p>
                        <div class="service-actions">
                            <button class="btn btn-sm btn-primary edit-service-btn"><i class="fas fa-edit"></i> 编辑</button>
                            <button class="btn btn-sm btn-danger delete-service-btn"><i class="fas fa-trash"></i> 删除</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 添加服务模态框 -->
<div class="modal" id="addServiceModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">添加新服务</h5>
                <button type="button" class="close" id="closeAddModal">&times;</button>
            </div>
            <div class="modal-body">
                <form id="serviceForm">
                    <div class="form-group">
                        <label>服务名称</label>
                        <input type="text" class="form-control" id="serviceName" required>
                    </div>
                    <div class="form-group">
                        <label>服务描述</label>
                        <textarea class="form-control" id="serviceDescription" rows="4" required></textarea>
                    </div>
                    <div class="form-group">
                        <label>服务图标</label>
                        <select class="form-control" id="serviceIconSelect" required>
                            <option value="laptop-code">网站开发</option>
                            <option value="mobile-alt">移动应用</option>
                            <option value="server">后端开发</option>
                            <option value="database">数据库</option>
                            <option value="cloud">云服务</option>
                            <option value="bug">代码优化</option>
                        </select>
                        <div class="icon-selector" id="iconSelector">
                            <div class="icon-option" data-icon="laptop-code">
                                <i class="fas fa-laptop-code"></i>
                                <span>网站</span>
                            </div>
                            <div class="icon-option" data-icon="mobile-alt">
                                <i class="fas fa-mobile-alt"></i>
                                <span>移动</span>
                            </div>
                            <div class="icon-option" data-icon="server">
                                <i class="fas fa-server"></i>
                                <span>后端</span>
                            </div>
                            <div class="icon-option" data-icon="database">
                                <i class="fas fa-database"></i>
                                <span>数据库</span>
                            </div>
                            <div class="icon-option" data-icon="cloud">
                                <i class="fas fa-cloud"></i>
                                <span>云服务</span>
                            </div>
                            <div class="icon-option" data-icon="bug">
                                <i class="fas fa-bug"></i>
                                <span>优化</span>
                            </div>
                            <div class="icon-option" data-icon="code">
                                <i class="fas fa-code"></i>
                                <span>代码</span>
                            </div>
                            <div class="icon-option" data-icon="palette">
                                <i class="fas fa-palette"></i>
                                <span>设计</span>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" id="cancelAddService">取消</button>
                <button type="button" class="btn btn-primary" id="saveService">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal" id="confirmDeleteModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">确认删除</h5>
                <button type="button" class="close" id="closeDeleteModal">&times;</button>
            </div>
            <div class="modal-body">
                <p>您确定要删除这个服务吗？此操作无法撤销。</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" id="cancelDelete">取消</button>
                <button type="button" class="btn btn-danger" id="confirmDelete">确认删除</button>
            </div>
        </div>
    </div>
</div>

<script>
    // 模态框控制
    const addServiceModal = document.getElementById('addServiceModal');
    const confirmDeleteModal = document.getElementById('confirmDeleteModal');

    // 显示添加服务模态框
    document.getElementById('addServiceBtn').addEventListener('click', () => {
        addServiceModal.classList.add('show');
        document.body.style.overflow = 'hidden';
    });

    // 关闭模态框的函数
    function closeModal(modal) {
        modal.classList.remove('show');
        document.body.style.overflow = '';
    }

    // 关闭添加服务模态框
    document.getElementById('closeAddModal').addEventListener('click', () => closeModal(addServiceModal));
    document.getElementById('cancelAddService').addEventListener('click', () => closeModal(addServiceModal));

    // 保存服务
    document.getElementById('saveService').addEventListener('click', () => {
        // 这里添加保存逻辑
        alert('服务保存成功！');
        closeModal(addServiceModal);
        document.getElementById('serviceForm').reset();
    });

    // 图标选择器交互
    document.querySelectorAll('.icon-option').forEach(option => {
        option.addEventListener('click', function() {
            // 移除所有选中状态
            document.querySelectorAll('.icon-option').forEach(opt => {
                opt.classList.remove('selected');
            });

            // 添加当前选中状态
            this.classList.add('selected');

            // 更新下拉选择框的值
            const iconValue = this.getAttribute('data-icon');
            document.getElementById('serviceIconSelect').value = iconValue;
        });
    });

    // 删除服务相关操作
    let currentDeleteItem = null;

    document.querySelectorAll('.delete-service-btn').forEach(btn => {
        btn.addEventListener('click', function() {
            currentDeleteItem = this.closest('.service-item');
            confirmDeleteModal.classList.add('show');
            document.body.style.overflow = 'hidden';
        });
    });

    // 关闭删除确认模态框
    document.getElementById('closeDeleteModal').addEventListener('click', () => closeModal(confirmDeleteModal));
    document.getElementById('cancelDelete').addEventListener('click', () => closeModal(confirmDeleteModal));

    // 确认删除
    document.getElementById('confirmDelete').addEventListener('click', () => {
        if (currentDeleteItem) {
            currentDeleteItem.style.animation = 'fadeOut 0.3s forwards';
            setTimeout(() => {
                currentDeleteItem.remove();
                alert('服务已删除！');
            }, 300);
        }
        closeModal(confirmDeleteModal);
    });

    // 编辑服务
    document.querySelectorAll('.edit-service-btn').forEach(btn => {
        btn.addEventListener('click', function() {
            const item = this.closest('.service-item');
            const title = item.querySelector('h4').textContent;
            const description = item.querySelector('p').textContent;
            const iconClass = item.querySelector('.service-icon i').className;
            const iconValue = iconClass.split(' ')[1];

            // 填充表单数据
            document.getElementById('serviceName').value = title;
            document.getElementById('serviceDescription').value = description;
            document.getElementById('serviceIconSelect').value = iconValue;

            // 设置选中的图标
            document.querySelectorAll('.icon-option').forEach(opt => {
                opt.classList.remove('selected');
                if (opt.getAttribute('data-icon') === iconValue) {
                    opt.classList.add('selected');
                }
            });

            // 显示模态框
            addServiceModal.classList.add('show');
            document.body.style.overflow = 'hidden';
        });
    });

    // 点击模态框外部关闭
    window.addEventListener('click', (e) => {
        if (e.target === addServiceModal) {
            closeModal(addServiceModal);
        }
        if (e.target === confirmDeleteModal) {
            closeModal(confirmDeleteModal);
        }
    });

    // 按ESC键关闭模态框
    document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape') {
            if (addServiceModal.classList.contains('show')) {
                closeModal(addServiceModal);
            }
            if (confirmDeleteModal.classList.contains('show')) {
                closeModal(confirmDeleteModal);
            }
        }
    });
</script>
</body>
</html>